package com.zwt.controller;

import com.zwt.service.UserRedPacketService;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * Created by zwt on 2018/6/6.
 */
@Controller
@RequestMapping("userRedPacket")
public class UserRedPacketController {

    @Autowired
    private UserRedPacketService userRedPacketService;

    @RequestMapping("grapRedPacket")
    @ResponseBody
    public Map<String,Object> grapRedPacket(Integer redPackageId,Integer userId){
        int result = userRedPacketService.grapRedPacket(redPackageId,userId);
        Map<String,Object> map = new HashedMap();
        map.put("flag",result);
        if(result<=0){
            map.put("msg","抢红包失败");
        }else{
            map.put("msg","抢红包成功");
        }
        return map;
    }
}
